# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1ExplainedPolicy do
  @moduledoc """
  Details about how a specific IAM Policy contributed to the access check.

  ## Attributes

  *   `access` (*type:* `String.t`, *default:* `nil`) - Indicates whether _this policy_ provides the specified permission to the specified principal for the specified resource. This field does _not_ indicate whether the principal actually has the permission for the resource. There might be another policy that overrides this policy. To determine whether the principal actually has the permission, use the `access` field in the TroubleshootIamPolicyResponse.
  *   `bindingExplanations` (*type:* `list(GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1BindingExplanation.t)`, *default:* `nil`) - Details about how each binding in the policy affects the principal's ability, or inability, to use the permission for the resource. If the sender of the request does not have access to the policy, this field is omitted.
  *   `fullResourceName` (*type:* `String.t`, *default:* `nil`) - The full resource name that identifies the resource. For example, `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. If the sender of the request does not have access to the policy, this field is omitted. For examples of full resource names for Google Cloud services, see https://cloud.google.com/iam/help/troubleshooter/full-resource-names.
  *   `policy` (*type:* `GoogleApi.PolicyTroubleshooter.V1.Model.GoogleIamV1Policy.t`, *default:* `nil`) - The IAM policy attached to the resource. If the sender of the request does not have access to the policy, this field is empty.
  *   `relevance` (*type:* `String.t`, *default:* `nil`) - The relevance of this policy to the overall determination in the TroubleshootIamPolicyResponse. If the sender of the request does not have access to the policy, this field is omitted.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :access => String.t() | nil,
          :bindingExplanations =>
            list(
              GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1BindingExplanation.t()
            )
            | nil,
          :fullResourceName => String.t() | nil,
          :policy => GoogleApi.PolicyTroubleshooter.V1.Model.GoogleIamV1Policy.t() | nil,
          :relevance => String.t() | nil
        }

  field(:access)

  field(:bindingExplanations,
    as:
      GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1BindingExplanation,
    type: :list
  )

  field(:fullResourceName)
  field(:policy, as: GoogleApi.PolicyTroubleshooter.V1.Model.GoogleIamV1Policy)
  field(:relevance)
end

defimpl Poison.Decoder,
  for: GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1ExplainedPolicy do
  def decode(value, options) do
    GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1ExplainedPolicy.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.PolicyTroubleshooter.V1.Model.GoogleCloudPolicytroubleshooterV1ExplainedPolicy do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
